#ifndef PERIOD_H
#define PERIOD_H

#include <QtGui>

#include "Date.h"

// A Class to hold one continous period of time. 
class Period : public QGraphicsObject
{
	Q_OBJECT

public:
	//! Constructor
	Period( QGraphicsItem* parent, int start = 0, int end = 0, Day day = MONDAY );	
	//! Destructor
	~Period();

	inline int startTime(){ return mStartTime; }
	inline int endTime(){ return mEndTime; }
	inline Day day(){ return mDay; }

	inline const QString& text() const { return mText; }
	inline void setText( const QString& text ){ mText = text; }

	// Graphics Item
	//! returns the bounding rectangle
	inline QRectF boundingRect() const { return boundRect; }
	//! Paints the item.
    void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget );
	//! Called when the user double clicks on the item.
	void mouseDoubleClickEvent( QGraphicsSceneMouseEvent* event );
	//! Called when the user clicks on a item.
	void mousePressEvent( QGraphicsSceneMouseEvent* event );
	//! Set the selection state for this item.
	inline void setSelection( bool selected ){ isSelected = selected; }

	void update();

public slots:
	void setStartTime( int startTime );
	void setEndTime( int endTime );
	void setDay( Day day );

signals:
	void selected( Period* period );
	void activated( Period* period );

private:
	int mStartTime;
	int mEndTime;
	Day mDay;
	int mRoomId;

	// Graphics Item
	QRectF boundRect;
	bool isSelected;
	QColor mColor;
	QColor mSelColor;

	QString mText;
};

#endif // PERIOD_H